<?php
	require '../config/config.php';
	require_once './api/config/config.php';
	if (empty($AppId) or empty($AuthAPI) or empty($API)) {
    echo "请配置config/config.php文件！";
}
	$ConfigSql="select * from config where id='1'";
	$ConfigInfo=mysqli_query($con,$ConfigSql);
	$ConnfigRs=mysqli_fetch_array($ConfigInfo);
	session_start();
	if(empty($_SESSION['member'])){
	    echo "<script>location='../../index.php';</script>";
	    exit;
	}
	if($_GET['ops']=="logout"){
	    $_SESSION['member']="";
	    session_destroy();
	    echo "<script>alert('您已退出登录！');location='../index.php';</script>";
	}
	if(!empty($_SESSION['member'])){
	    //$UserSql=mysqli_query($con,"select * from member while user='".$_SESSION['member']."'");
		//$UserInfo=mysqli_fetch_array($UserSql);
		$UserSql="SELECT * FROM `member` WHERE user='".$_SESSION['member']."'";
		$UserInfo=mysqli_query($con,$UserSql);
		@$UserRs=mysqli_fetch_array($UserInfo);
		$urs=mysqli_query($con,"SELECT * FROM `link` WHERE user='".$_SESSION['member']."'");
		@$rs=mysqli_fetch_array($urs);
		//echo "<script>alert('".$UserInfo['type']."');</script>";
	}
	if($_GET['ops']=="link"){
	    $_SESSION['link']="yes";
	    echo "<script>location='".$AuthAPI."?Id=".$AppId."';</script>";
	}
	if($_GET['ops']=="nolink"){
	    $_SESSION['link']="no";
	    mysqli_query($con,"DELETE  FROM `link` WHERE user='".$_SESSION['member']."'");
	    echo "<script>location='./my.php';</script>";
	}
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title><?php echo $ConnfigRs['name'];?>-个人中心</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../css/head.css"/>
  <link rel="stylesheet" href="../layui/css/layui.css">

<link rel="stylesheet" href="../css/global.css">

<script src="../layui/layui.js"></script>
</head>
<body >

<div class="dvhead">
	<div class="dvlogo"><a href="../../../index.php">校园服务反馈系统</a></div>
	<div class="dvreg">
		<?php
		    if(empty($_SESSION['member'])){
                echo "已有账号，立即&nbsp;<a href='login.php'>登录</a>";
            }else{
                echo "欢迎您，".$_SESSION['member']." &nbsp;&nbsp;<a href='?ops=logout'> 退出</a>";
            }
		?>
	</div>
</div>

<div class="main layui-clear">
  <div class="fly-panel" pad20>
    <div class="layui-form layui-form-pane">
		<form method="post">
			<table class="news-edit">
				<tr>
					<th>账&nbsp;&nbsp;&nbsp;号：</th>
					<td><?php echo $UserRs['user'];?></td>
				</tr>
				<tr>
					<th>邮&nbsp;&nbsp;&nbsp;箱：</th>
					<td><?php echo $UserRs['email'];?> &nbsp;<a href="JavaScript:alert('邮箱更换服务正在开发中！');">更换</a></td>
				</tr>
				<tr>
					<th>密&nbsp;&nbsp;&nbsp;码：</th>
					<td><a href="./resetpwd/index.php">修改密码</a></td>
				</tr>
				<tr>
					<th>注&nbsp;&nbsp;&nbsp;销：</th>
					<td><a href="./del/index.php">注销账号</a></td>
				</tr>
				<tr>
					<th>绑&nbsp;&nbsp;&nbsp;定：</th>
					<td>
					    <?php 
					        if(!empty($rs['id'])){
					            echo "<a href='?ops=nolink'>解除绑定</a>华宇通行证";
					        }else{
					            echo "<a href='?ops=link'>绑定</a>华宇通行证";
					        }
					    ?>
					</td>
				</tr>
				<tr>
					<th>订&nbsp;&nbsp;&nbsp;单：</th>
					<td><a href="../pay/index.php">我的订单</a></td>
				</tr>
			</table>
		</form>
    </div>
  </div>
</div>

 <script type="text/javascript" charset="utf-8" src="js/kindeditor.js"></script>
  <script type="text/javascript">
    KE.show({
        id : 'content',
		resizeMode : 1,
        cssPath : './index.css',
        items : [
        'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
        'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
        'insertunorderedlist', 'emoticons', 'image', 'link']
    });
  </script>
<script>

layui.cache.page = '';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '../res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "2.0.0"
  ,base: '../res/mods/'
}).extend({
  fly: 'index'
}).use('fly');
</script>
</body>
</html>